package jp.com.nobnak.commentviewer.webview;

import jp.com.nobnak.commentviewer.util.IntentUtil;
import jp.com.nobnak.commentviewer.util.UriCommandLauncher;
import android.content.Intent;
import android.net.Uri;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class LoginWebClient extends WebViewClient {
	private UriCommandLauncher mLauncher;

	public LoginWebClient(UriCommandLauncher launcher) { 
		mLauncher = launcher;
	}

	@Override
	public boolean shouldOverrideUrlLoading(WebView view, String url) {
		Uri uri = Uri.parse(url);

		if (mLauncher.launch(uri))
			return true;

		Intent browser = IntentUtil.getBrowserOpenUriIntent(uri);
		view.getContext().startActivity(browser);
		return true;
	}
}
